package com.sg.business.model.dataset.vault;

import com.sg.business.model.Document;
import com.sg.business.model.Folder;
import com.sg.business.model.IModelConstants;
import com.sg.widgets.commons.dataset.MasterDetailDataSetFactory;

public class FolderOfContainer extends MasterDetailDataSetFactory {

	public FolderOfContainer() {
		super(IModelConstants.DB, IModelConstants.C_FOLDER);
	}

	@Override
	protected String getDetailCollectionKey() {
		return Folder.F__ID;
	}
	
	@Override
	protected Object getMasterValue() {
		if(master instanceof Document) {
			Document document = (Document) master;
			Folder folder = document.getFolder();
			if(folder.isContainer()) {
				return folder.get_id();
			}else {
				return folder.getContainer().get_id();
			}
		}
		return null;
	}
}
